<?php

declare (strict_types=1);

namespace App\Model;

use Hyperf\DbConnection\Model\Model;

/**
 * @property Cooperative $cooperative
 * @property int id
 * @property int cooperative_id
 * @property false|\Hyperf\Utils\HigherOrderTapProxy|mixed|string|void|null password
 * @property \Hyperf\Utils\HigherOrderTapProxy|mixed|string|void|null username
 * @property \Hyperf\Utils\HigherOrderTapProxy|mixed|string|void|null contact
 * @property \Hyperf\Utils\HigherOrderTapProxy|mixed|string|void|null mobile
 * @property \Hyperf\Utils\HigherOrderTapProxy|int|mixed|void|null is_manager
 */
class CooperativeUser extends Model
{
    /**
     * The table associated with the model.
     *
     * @var string
     */
    protected $table = 'cooperative_user';
    /**
     * The attributes that are mass assignable.
     *
     * @var array
     */
    protected $fillable = ['mobile', 'username', 'cooperative_id','position'];

    protected $hidden = ['password'];

    /**
     * The attributes that should be cast to native types.
     *
     * @var array
     */
    protected $casts = [];

    public function cooperative()
    {
        return $this->belongsTo(Cooperative::class);
    }

    public function isManager()
    {
        return $this->is_manager == \App\Constants\Model\CooperativeUser::IS_MANAGER_YES;
    }
}